package com.csy.blog.service.web;

import com.csy.blog.service.domain.User;
import com.csy.blog.service.service.UserService;
import com.csy.blog.service.utils.PageQuery;
import com.csy.blog.service.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;
import java.util.UUID;

@RestController
@RequestMapping(value = "users")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping
    public Result query(PageQuery pageQuery) {
        return userService.query(pageQuery);
    }
    @PostMapping
    public String save(Locale locale, Model model, @PathVariable String userName) {
        User user = new User();
        user.setId(UUID.randomUUID().toString().replaceAll("-",""));
        userService.save(user);
        return "hello";
    }
}
